<?php
/***************************************************************************
 *   copyright : (C) 2009 Udrea Cristian
 *   site : http://code.google.com/p/testauction-php
 ***************************************************************************/

/***************************************************************************
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as 
 *   published by the Free Software Foundation; either version 2 of the
 *   License, or (at your option) any later version. Although none of the
 *   code may be sold. If you have been sold this script, get a refund.
 ***************************************************************************/
//DE VERIFICAT POST-UL PENTRU LOGIN PE CELELALTE SITE-URI
include("include/session.php");
require_once("HTML/Template/IT.php");

require_once("classes/class.element.php");
include ("classes/class.tooltips.php");
include ("element.clock.php");
include ("element.progress.php");
include ("element.tabcontrol.php");
include ("element.auctionsold.php");
include ("element.auctionactive.php");

$template = new HTML_Template_IT("templates/");
$template->loadTemplateFile("default.tpl");

$template->setCurrentBlock("clock_script");
$template->setVariable("CLOCKSCRIPT", $clock->getContents());
$template->parseCurrentBlock();

$template->setCurrentBlock("clock");
$template->setVariable("CLOCKPLACEHOLDER", $clock->toString());
$template->parseCurrentBlock();

if($session->logged_in){
	require_once("include/classes/class.AuctionHandler.php");
	$creditinfo = $auctionDB->getUserCreditInfo($session->username);
	
	$template->setCurrentBlock("user_box");
	$template->setVariable("USERNAME", $session->username);
	$template->setVariable("CREDITBALANCE", $creditinfo['credit_balance']);
	$creditbar->setProgress(100 - (100 * $creditinfo['offers_left'])/BONUS_OFFER_COUNT);
	$creditbar->setTooltipText("Mai aveti " . $creditinfo['offers_left'] . " oferte pana la urmatorul bonus");
	$template->setVariable("CREDITPROGRESSBAR", $creditbar->toString());
	$template->parseCurrentBlock();
}else{
	include ('elements/element.loginbox.php');
	if(isset($_GET['page'])) {
		$login_box->setPage($_GET['page']);
	}
	$template->setCurrentBlock("login_box");
	$template->setVariable("LOGINBOX", $login_box->toString());
	$template->parseCurrentBlock();
	
	/*if($form->num_errors > 0){
		$template->setCurrentBlock("table_page");
		$template->setVariable("TABLEPAGECONTENT", $login_box->showErrors());
		$template->parseCurrentBlock();
	}*/
}
?>
